package design.pattern.prototype.deep;

import java.time.LocalDateTime;

/**
 * @description:
 * @author: liuzhangcheng
 **/
public class DeepPrototypeTest {
    public static void main(String[] args) {
        QiTianDaSheng prototype = new QiTianDaSheng();
        prototype.setWeight(140);
        prototype.setHeight(180);
        prototype.setDate(LocalDateTime.now());
        prototype.setJinGuBang(new JinGuBang(234, 111));

        try {
            QiTianDaSheng prototypeClone = (QiTianDaSheng) prototype.clone();

            System.out.println("原型对象：" + prototype);
            System.out.println("克隆对象：" + prototypeClone);
            System.out.println("原型对象引用JiGuBang对象地址：" + prototype.getJinGuBang());
            System.out.println("克隆对象引用JiGuBang对象地址：" + prototypeClone.getJinGuBang());
            // 结果为false
            System.out.println("原型与克隆对象引用List对象地址比较：" + (prototype.getJinGuBang() == prototypeClone.getJinGuBang()));

        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }



    }
}
